import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

//官方配置：解决 VueRouter 中同一路由多次切换报错问题
const original = Router.prototype.push;
Router.prototype.push = function push(location) {
    return original.call(this, location).catch(err => err)
};

export default new Router(
    {
        mode: 'history',
        routes: [
            //默认
            {
                path: '*',
                redirect: '/login'
            },
            //主页
            {
                path: '/index',
                name: 'Index',
                component: () => import('../views/Index')
            },
            //登录页
            {
                path: '/login',
                name: 'Login',
                component: () => import('../views/login/Login')
            },
            //注册页
            {
                path: '/register',
                name: 'Register',
                component: () => import('../views/login/Register')
            },
            //发布文章页
            {
                path: '/publish',
                name: 'Publish',
                component: () => import('../views/article/Publish')
            },
            //个人主页
            {
                path: '/personal',
                name: 'Personal',
                component: () => import('../views/personal/Personal'),
                children: [

                    {
                        //帖子内容

                        path: '/post',
                        name: 'Post',
                        component: () => import('../views/post/Post')
                    },
                    {

                        //粉丝

                        path: '/fans',
                        name: 'Fans',
                        component: () => import('../views/fans/Fans')
                    },
                    //关注
                    {
                        path: '/attention',
                        name: 'Attention',
                        component: () => import('../views/attention/Attention')

                    }

                ]





            }
            ,//编辑个人资料
            {
                path: '/compile',
                name: 'Compile',
                component: () => import('../views/compile/Compile')
            }
            ,


        ]
    })
